﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GenTerrain : MonoBehaviour {
    public GameObject GrassPrefab, SandPrefab;
    public GameObject MCPlayer;
    public int x;
    public int z;
    public int HeightScale;
    public float DetailScale;
    // Use this for initialization
    void Start () {
        int seed = (int)Network.time * 10;
        for (int i = 0; i < x; i++)
        {
            for (int j = 0; j < z; j++)
            {
                float xCoord = (i + seed) / DetailScale;
                float yCoord = (j + seed) / DetailScale;
                int y = (int) (Mathf.PerlinNoise(xCoord, yCoord) * HeightScale);
                GameObject.Instantiate(GrassPrefab, new Vector3(i, y, j), Quaternion.identity);
                if (y > 15) {
                    GameObject.Instantiate(GrassPrefab, new Vector3(i, y, j), Quaternion.identity);
                } else {
                    GameObject.Instantiate(SandPrefab, new Vector3(i, y, j), Quaternion.identity);
                }
            }
        }
    }

    // Update is called once per frame
    void Update () {
        
    }
}
